//
//  sexChooseVC.m
//  YiXiu
//
//  Created by ZHY on 16/7/15.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "sexChooseVC.h"

@interface sexChooseVC ()

#define sexX  0
#define sexY  84
#define sexW  KScreenWidth - sexX*2
#define sexH  40


@property (nonatomic, strong) UIButton *oppositeSex;
@property (nonatomic, strong) UIButton *gayBtn;
@property (nonatomic, strong) UIButton *doubleBtn;
@property (nonatomic, strong) UIButton *secretBtn;
//这只是一条无情的分割线
@property (nonatomic, strong) UIImageView *lineView;
@property (nonatomic, strong) UIImageView *lineTowView;

@property (nonatomic, assign) __block BOOL image1Hidden;
@property (nonatomic, assign) __block BOOL image2Hidden;
@property (nonatomic, assign) __block BOOL image3Hidden;

@end

@implementation sexChooseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColorFromRGB(0xefeff4);
    
//    [self.view addSubview:self.oppositeSex];
//    [self.view addSubview:self.gayBtn];
//    [self.view addSubview:self.doubleBtn];
    
//    [self.view addSubview:self.secretBtn];
    self.image1Hidden = YES;
    self.image2Hidden = YES;
    self.image3Hidden = YES;
    
    [self addThreeGroupWithRefreshData:NO];
    
}


-(void)addThreeGroupWithRefreshData:(BOOL)isOK
{
    
    EventSettingItem *setting = [EventSettingItem itemWithText:@"异性恋" image:nil type:EventSettingItemTypeSelectArrow viewTag:buildScheduleType arrowImageName:@"guoguo" isArrowHidden:self.image1Hidden];
    
    setting.operation = ^{
        self.image1Hidden = NO;
        self.image2Hidden = YES;
        self.image3Hidden = YES;
        
        [self.tableView reloadData];
        [self addThreeGroupWithRefreshData:YES];
    };
    
    EventSettingItem *setting1 = [EventSettingItem itemWithText:@"同性恋" image:nil type:EventSettingItemTypeSelectArrow viewTag:buildScheduleType arrowImageName:@"guoguo" isArrowHidden:self.image2Hidden];
    setting1.operation = ^{
        self.image1Hidden = YES;
        self.image2Hidden = NO;
        self.image3Hidden = YES;
        
        [self.tableView reloadData];
        [self addThreeGroupWithRefreshData:YES];
    };

    
    EventSettingItem *setting2 = [EventSettingItem itemWithText:@"双性恋" image:nil type:EventSettingItemTypeSelectArrow viewTag:buildScheduleType arrowImageName:@"guoguo" isArrowHidden:self.image3Hidden];
    
    setting2.operation = ^{
        self.image1Hidden = YES;
        self.image2Hidden = YES;
        self.image3Hidden = NO;
        
        [self.tableView reloadData];
        [self addThreeGroupWithRefreshData:YES];
    };
  
    EventSettingGroup *group = [[EventSettingGroup alloc] init];
    
    group.rowHeight = 60;
    
    group.items = @[setting,setting1,setting2];
    
    
    if (isOK) {
        [self.allGroups replaceObjectAtIndex:0 withObject:group];
    }else{
        [self.allGroups addObject:group];
    }
    
}















//异性恋选择按钮
-(UIButton *)oppositeSex{

    if (!_oppositeSex) {
        _oppositeSex = [[UIButton alloc]initWithFrame:CGRectMake(sexX, sexY, sexW, sexH)];
        _oppositeSex.backgroundColor = [UIColor whiteColor];
        _oppositeSex.tag = 100;
        [_oppositeSex setTitle:@"异性恋" forState:UIControlStateNormal];
        
        [_oppositeSex setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        //设置一根无聊的分割线
        if(!_lineView){
            
            _lineView = [[UIImageView alloc]initWithFrame:CGRectMake(20, sexH-1, KScreenWidth-20, 1)];
            _lineView.backgroundColor =[UIColor grayColor];
            
            [_oppositeSex addSubview:_lineView];
            
        }
        //设置文字居左显示
        _oppositeSex.titleEdgeInsets = UIEdgeInsetsMake(5, 20, 5, KScreenWidth - 100);
        
        
    }

    return _oppositeSex;
}


-(UIButton *)gayBtn{
    //同性恋选择按钮
    if (!_gayBtn) {
        _gayBtn = [[UIButton alloc]initWithFrame:CGRectMake(sexX, sexY+sexH, sexW, sexH)];
        _gayBtn.tag = 101;
        _gayBtn.backgroundColor = [UIColor whiteColor];
        [_gayBtn setTitle:@"同性恋" forState:UIControlStateNormal];
        [_gayBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        if(!_lineTowView){
            
            _lineTowView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 39, KScreenWidth-20, 1)];
            _lineTowView.backgroundColor =[UIColor grayColor];
            
            [_gayBtn addSubview:_lineTowView];
        }
        
        //设置文字居左显示
        _gayBtn.titleEdgeInsets = UIEdgeInsetsMake(5, 20, 5, KScreenWidth - 100);
//        [_gayBtn addSubview:_lineView];
    }
    return _gayBtn;
}

-(UIButton *)doubleBtn{
    
    //双性恋选择按钮
    if (!_doubleBtn) {
        _doubleBtn = [[UIButton alloc]initWithFrame:CGRectMake(sexX, sexY+sexH*2, sexW, sexH)];
        _doubleBtn.tag = 102;
        _doubleBtn.backgroundColor = [UIColor whiteColor];
        if(!_lineTowView){
            
            _lineTowView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 39, KScreenWidth-20, 1)];
            _lineTowView.backgroundColor =[UIColor grayColor];
            
            [_oppositeSex addSubview:_lineTowView];
        }
        [_doubleBtn setTitle:@"双性恋" forState:UIControlStateNormal];
        [_doubleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        //设置文字居左显示
        _doubleBtn.titleEdgeInsets = UIEdgeInsetsMake(5, 20, 5, KScreenWidth - 100);
        
        
    }
    return _doubleBtn;
    
    
    
}

//是否保密
-(UIButton *)secretBtn{
    
    if(!_secretBtn){
        
        _secretBtn = [[UIButton alloc]init];
        [_secretBtn setTitle:@"保密" forState:UIControlStateNormal];
        [_secretBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _secretBtn.backgroundColor = [UIColor whiteColor];
        
        [_secretBtn setImage:[UIImage imageNamed:@"square"] forState:UIControlStateNormal];
        [_secretBtn setImage:[UIImage imageNamed:@"square_Sel"] forState:UIControlStateSelected];
        _secretBtn.frame = CGRectMake(20, sexY+sexH*3+20, 100, 30);
        
        
    }

    return _secretBtn;

}









@end
